package com.obas.integration.dpi.service.impl;

import java.util.Date;

import com.ease.common.util.DateFormatUtil;
import com.ease.common.util.DateUtil;
import com.obas.integration.common.service.impl.AbstractIntegrationFileServiceImpl;
import com.obas.integration.dpi.service.DpiIntegrationFileService;

public class DpiIntegrationFileServiceImpl extends AbstractIntegrationFileServiceImpl implements DpiIntegrationFileService {

	public void doLoad(String fileNamePrefix, Date batchTimestamp, final String controlTemplateName) {

		String fileName = fileNamePrefix + DateFormatUtil.toDatatimeNumberString(batchTimestamp) + ".txt";

		this.load(fileName, batchTimestamp, controlTemplateName);
	}

	public void loadDpiSession() {
		String fileNamePrefix = "session_";
		String controlTemplateName = "dpi.session.ctl.ftl";

		Date date = new Date();
		Date batchTimestamp = DateUtil.getLastHalfHourDate(date);

		this.doLoad(fileNamePrefix, batchTimestamp, controlTemplateName);
	}

	public void loadDpiRadius() {
		String fileNamePrefix = "RADIUS_";
		String controlTemplateName = "dpi.radius.ctl.ftl";

		Date date = new Date();
		Date batchTimestamp = DateUtil.getLastHalfHourDate(date);

		this.doLoad(fileNamePrefix, batchTimestamp, controlTemplateName);
	}

	public void loadDpiKpi() {
		String fileNamePrefix = "KPI_";
		String controlTemplateName = "dpi.kpi.ctl.ftl";

		Date date = new Date();
		Date batchTimestamp = DateUtil.getLastHalfHourDate(date);

		this.doLoad(fileNamePrefix, batchTimestamp, controlTemplateName);
	}

	public void loadDpiAppid() {
		String fileNamePrefix = "APPID_";
		String controlTemplateName = "dpi.appid.ctl.ftl";

		Date date = new Date();
		Date batchTimestamp = DateUtil.getLastHalfHourDate(date);

		this.doLoad(fileNamePrefix, batchTimestamp, controlTemplateName);
	}
}
